<?php

namespace app\admin\controller;

use app\models\Admin;
use think\Db;

use app\models \{
    User,
    CoinLog
};

class Main extends Base
{
    public function index()
    {
        $admin = $this->request->admin;
        $menu = config('menu.menu');
        $arr = [];
//        $roles =explode(",",$admin['role']);
        $roles=$admin['role'];
        foreach ($menu as $k => $v) {
            if ($v['show'] == true) {
                foreach ($v['sub'] as $x => $y) {
                    if ( $admin['is_default'] == 1|| ($y['show'] == true && in_array($y['uri'],$roles))) {
                        $arr[$k]['name'] = $v['name'];
                        $arr[$k]['ico'] = $v['ico'];
                        $arr[$k]['sub'][$x] = $y;
                    }
                }
            }
        }
        return view(null, [
            'admin' => $admin,
            'menu' => $arr,
        ]);
    }

    public function welcome()
    {

        $admin = $this->request->admin;
        $data = array();
         return view(null, [
            'admin' => $this->request->admin,
            'data' => $data,
        ]);
    }

    public function miss()
    {
        return view('404');
    }
}
